<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>
<head>
<title><spring:message code="admin.viewlicense.title" /></title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="<c:url value="/css/styles.css"/>" />
<script src="<c:url value="/javascripts/common.js"/>"></script>
<script language="javascript" type="text/javascript">
function ch_select_byname(flag, name) {
	var ch = flag || false;
	var inputs = document.getElementsByTagName("input");
	for (var i=0;i<inputs.length;i++) {
		if(inputs[i].type == "checkbox") {
            if(name !=undefined ){
                if(inputs[i].name==name){
			        inputs[i].checked = ch;
                }
            }else{
               inputs[i].checked = ch; 
            }
		}
	}
	return false;
}

function download( id ){
	document.location.href = "download_license.htm?id="+id;
}
</script>
<script language="javascript">
// script added by Umme Essa. The form should be validated on all operations.
 
	 function validateForm(){
		  
			if(isAnyCheckBoxSelected("selector"))return true;
			else {
				alert("Please select a record to remove");
				return false;
			}
			 
		 }
		 
 
	 function isAnyCheckBoxSelected(selecter){
		 var items = document.forms[0].elements[selecter];
		 var length=getLength(items);
		 var item=null;
		 	for(i=0;i<length;i++)
		 	{	item=getItemAt(items,i);
		 		if(item.checked)
		 			return true;
		 	}
		 return false;
		 }

		
		 
	 </script>
</head>

<body><%@include file="../top_menu.jsp"%>

<table width=100%>
	<tr>
		<td><c:import url="/WEB-INF/jsp/menu/admin_license_menu.jsp" />
		<br />
		</td>
	</tr>
	<tr>
		<td><%@include file="/WEB-INF/jsp/include/messages.jsp"%>
		<br />
		</td>
	</tr>
</table>
<form action="delete_licenses.htm" method="post"
	onsubmit="return validateForm()">
<table width=70% class="formTable" cellspacing="0">
	<tr class="ui-state-default">
		<c:if test="${licenseList.pageNumber>1}">
			<td align="left"><a
				href="view_licenses.htm?pageNo=${licenseList.pageNumber-1}&sortColumn=${licenseList.sortColumn}"
				class="mouseEffect"><span class="ui-icon ui-icon-seek-prev"
				style="float: left;"></span><spring:message code="admin.viewlicense.button.previousepage" /></a></td>
		</c:if>
		<c:if test="${licenseList.pageNumber<licenseList.pagesAvailable}">
			<td align="right"><a
				href="view_licenses.htm?pageNo=${licenseList.pageNumber+1}&sortColumn=${licenseList.sortColumn}"
				class="mouseEffect"><span class="ui-icon ui-icon-seek-next"
				style="float: right;"></span><spring:message code="admin.viewlicense.button.nextpage" /></a></td>
		</c:if>
	</tr>
</table>
<table width=70% class="formTable">
	<tr class="formHeader">
		<td colspan="11"><spring:message code="admin.viewlicense.label.licenses" /></td>
	</tr>
	<tr>
		<td align="center"><input type="checkbox"
			onclick="ch_select_byname(this.checked,'ids')" /></td>
		<th>#</th>
		<th><a	href="view_licenses.htm?pageNo=${licenseList.pageNumber}&sortColumn=name&sortOrder=${aclClassList.sortOrder}"
				class="headerLink" style="cursor: pointer;" title="${licenseList.sortOrder}"><spring:message code="admin.viewlicense.label.licensename" /></a></th>
		<th><a	href="view_licenses.htm?pageNo=${licenseList.pageNumber}&sortColumn=text&sortOrder=${licenseList.sortOrder}"
				class="headerLink" style="cursor: pointer;" title="${licenseList.sortOrder}"><spring:message code="admin.viewlicense.label.text" /></a></th>
		<th><a	href="view_licenses.htm?pageNo=${licenseList.pageNumber}&sortColumn=comments&sortOrder=${licenseList.sortOrder}"
				class="headerLink" style="cursor: pointer;" title="${licenseList.sortOrder}"><spring:message code="admin.viewlicense.label.comments" /></a></th>
		<th align="center"><spring:message code="admin.viewlicense.label.attachments" /></th>
		<th><spring:message code="admin.viewlicense.label.active" /></th>
	</tr>
	<tbody>
		<c:if test="${empty licenseList}">
			<tr>
				<td colspan="7"><spring:message code="admin.viewlicense.label.nolicensewerefound" /></td>
			</tr>
		</c:if>

		<c:forEach var="r" items="${licenseList.pageItems}" varStatus="i">
			<tr class="tr_record">
				<td align="center"><input type="checkbox" id="selector"
					class="License" name="ids" value="${r.id}"></input></td>
				<td align="center">${i.count+(licenseList.recordSize*(licenseList.pageNumber-1))}</td>
				<td><a
					href="<c:url value="/admin/license/edit_license.htm?id=${r.id}"/>">${r.name}</a></td>
				<td>${r.text}</td>
				<td><c:out value="${r.comments}" default="" /></td>
				<td align="center"><c:if test="${fn:length(r.attachments)>0}">
					<a
						href="<c:url value="/admin/license/download_license.htm?id=${r.id}"/>"
						target="_blank"><spring:message code="admin.viewlicense.label.download" /> ${r.filename}</a>
				</c:if></td>
				<td align="center"><input type="checkbox"
					<c:if test="${r.active}">checked</c:if>
					onclick="this.checked=!this.checked" /></td>
			</tr>
		</c:forEach>
		<c:if test="${!empty licenseList}">
			<tr>
				<td colspan="7"><input type="submit"
					class='ui-button ui-state-default ui-corner-all' value="<spring:message code="admin.viewlicense.button.remove" />" /></td>
			</tr>
		</c:if>
	</tbody>
</table>
<table width=70% class="formTable" cellspacing="0">
	<tr class="ui-state-default">
		<c:if test="${licenseList.pageNumber>1}">
			<td align="left"><a
				href="view_licenses.htm?pageNo=${licenseList.pageNumber-1}&sortColumn=${licenseList.sortColumn}"
				class="mouseEffect"><span class="ui-icon ui-icon-seek-prev"
				style="float: left;"></span><spring:message code="admin.viewlicense.button.previousepage" /></a></td>
		</c:if>
		<c:if test="${licenseList.pageNumber<licenseList.pagesAvailable}">
			<td align="right"><a
				href="view_licenses.htm?pageNo=${licenseList.pageNumber+1}&sortColumn=${licenseList.sortColumn}"
				class="mouseEffect"><span class="ui-icon ui-icon-seek-next"
				style="float: right;"></span><spring:message code="admin.viewlicense.button.nextpage" /></a></td>
		</c:if>
	</tr>
</table>
</form><%@include file="/WEB-INF/jsp/include/footer.jsp"%>
</body>
</html>